/**
 * created since 2010-9-7
 */
package com.liwei.jdbc.test1;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;

public class convertrdate {
	public static void main(String[] args) throws InstantiationException,
			IllegalAccessException, ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver").newInstance();
		Connection con = java.sql.DriverManager
				.getConnection(
						"jdbc:mysql://localhost:3306/lib?useUnicode=true&characterEncoding=UTF-8",
						"root", "root");
		Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
				ResultSet.CONCUR_UPDATABLE);
		ResultSet rst = stmt.executeQuery("select * from feedback");
		while (rst.next()) {
			String str = rst.getString("rdate");
			String id = rst.getString("id");
			if (str != null)
				if (!str.equals("")) {
					System.out.println(id + "--" + str);
					Date date = new Date(str);
					SimpleDateFormat df = new SimpleDateFormat(
							"yyyy-MM-dd hh:mm:ss");
					rst.updateString("rdate", df.format(date));
					rst.updateRow();
				}
		}

		rst.close();
		stmt.close();
		con.close();
	}
}
